<?php
namespace app\http\middleware;

class CheckUser
{
    /**
     * 用户登录验证
     * @param \think\Request $request
     * @param \Closure $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        if (!session('user_id')) {
            return json(['code' => 401, 'msg' => '请先登录']);
        }
        return $next($request);
    }
} 